POV-Ray : Newsgroups : povray.advanced-users : function optimization question : Re: function optimization question Server Time
29 Jul 2024 18:18:47 EDT (-0400)
  Re: function optimization question  
From: Warp
Date: 31 Mar 2002 21:52:55
Message: <3ca7cb87@news.povray.org>
I think that the problem with self-modifying code nowadays is that, if
supported by the processor (not all processors support that; in them the
code to be executed is read-only), it effectively kills most optimizations
performed by the processor.
  If the code being executed is modified, it invalidates the pipelines and
perhaps even the code in the cache, plus all the branch prediction stuff
and so on. This causes the same effect as loading the code from RAM for
the first time. If this is done in each loop, it's extremely slow.
  If a very tight loop modifies itself, it could result in a code which
is several tens of times slower than an equivalent code with no
self-modification.

  Of course self-modification is ok if you first modify the code to be
executed, and then this code is executed for a long period of time.
  In fact, the OS does exactly this when it loads an exe file to memory:
It modifies its long jump addresses to match the place in memory where it
loaded it (with the help of the relocation table which can be found in
the header of the exe file).

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.